<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<html>
<head>
<title>VM Spec  </title>
</head>
<body BGCOLOR=#eeeeff text=#000000 LINK=#0000ff VLINK=#000077 ALINK=#ff0000>
<table width=100%><tr>
<td><a href="VMSpecTOC.doc.html">Contents</a> | <a href="Instructions2.doc11.html">Prev</a> | <a href="Instructions2.doc13.html">Next</a> | <a href="VMSpecIX.fm.html">Index</a></td><td align=right><i><i>The Java<sup><font size=-2>TM</font></sup> Virtual Machine Specification</i></i></td>
</tr></table>


<hr><br>
 
<a href="Instructions2.doc.html">A</a>
<a href="Instructions2.doc1.html">B</a>
<a href="Instructions2.doc2.html">C</a>
<a href="Instructions2.doc3.html">D</a>
<a href="Instructions2.doc4.html">F</a>
<a href="Instructions2.doc5.html">G</a>
<a href="Instructions2.doc6.html">I</a>
<a href="Instructions2.doc7.html">J</a>
<a href="Instructions2.doc8.html">L</a>
<a href="Instructions2.doc9.html">M</a>
<a href="Instructions2.doc10.html">N</a>
<a href="Instructions2.doc11.html">P</a>
<a href="Instructions2.doc12.html">R</a>
<a href="Instructions2.doc13.html">S</a>
<a href="Instructions2.doc14.html">T</a>
<a href="Instructions2.doc15.html">W</a>

<a name="ret"></a>
<hr><h2>ret</h2>
<a name="ret.Operation"></a>
<p><b>Operation</b><br>
<blockquote><a name="70002"></a>
Return from subroutine<p><Table Border="1">
</blockquote>

<p><b>Format</b><br>
<blockquote>

<tr><td><a name="69999"></a>
 <i>ret</i>
<td><a name="87568"></a>
 

<tr><td><a name="70001"></a>
 <i>index</i>
<td><a name="87568"></a>
 

</Table><br></blockquote><p>
<a name="ret.Forms"></a>
<p><b>Forms</b><br>
<blockquote><a name="70003"></a>
<i>ret</i> = 169 (0xa9)</blockquote><p>
<a name="ret.Operand"></a>
<p><b>Operand Stack</b><br>
<blockquote><a name="70004"></a>
No change</blockquote><p>
<a name="ret.Description"></a>
<p><b>Description</b><br>
<blockquote><a name="70005"></a>
The <i>index</i> is an unsigned byte between 0 and 255, inclusive. <em>The local variable </em>at<em> </em><i>index</i> in t<em>he current frame </em><a href="Overview.doc.html#17257">(&#167;3.6)</a><em> must contain a value of type </em><code>returnAddress</code><em>. </em>The contents of the local variable are written into the Java virtual machine's <code>pc</code> register, and execution continues there.</blockquote><p>
<a name="ret.Notes"></a>
<p><b>Notes</b><br>
<blockquote><a name="70009"></a>
The <i>ret</i> instruction is used with <i>jsr</i> or <i>jsr_w</i> instructions in the implementation of the <code>finally</code> clauses of the Java programming language (see <a href="Compiling.doc.html#13789">Section 7.13, "Compiling <code>finally</code>"</a>). Note that <i>jsr</i> pushes the address onto the operand stack and <i>ret</i> gets it out of a local variable. This asymmetry is intentional.</blockquote><p>
<blockquote><a name="100993"></a>
The <i>ret</i> instruction should not be confused with the <i>return</i> instruction. A <i>return</i> instruction returns control from a method to its invoker, without passing any value back to the invoker.</blockquote><p>
<blockquote><a name="166941"></a>
The <i>ret</i> opcode can be used in conjunction with the <i>wide</i> instruction to access a local variable using a two-byte unsigned index.</blockquote><p>
<blockquote><a name="166939"></a>
</blockquote><p>

<a name="return"></a>
<hr><h2>return</h2>
<a name="return.Operation"></a>
<p><b>Operation</b><br>
<blockquote><a name="70019"></a>
Return <code>void</code> from method<p><Table Border="1">
</blockquote>

<p><b>Format</b><br>
<blockquote>

<tr><td><a name="70018"></a>
 <i>return</i>
<td><a name="87568"></a>
 

</Table><br></blockquote><p>
<a name="return.Forms"></a>
<p><b>Forms</b><br>
<blockquote><a name="70020"></a>
<i>return</i> = 177 (0xb1)</blockquote><p>
<a name="return.Operand"></a>
<p><b>Operand Stack</b><br>
<blockquote><a name="70021"></a>
... <img src="chars/arrwdbrt.gif">  [empty]</blockquote><p>
<a name="return.Description"></a>
<p><b>Description</b><br>
<blockquote><a name="70022"></a>
The current method must have return type <code>void</code>. If the current method is a <code>synchronized</code> method, the monitor acquired or reentered on invocation of the method is released or exited (respectively) as if by execution of a <i>monitorexit</i> instruction. If no exception is thrown, any values on the operand stack of the current frame <a href="Overview.doc.html#17257">(&#167;3.6)</a> are discarded.</blockquote><p>
<blockquote><a name="70026"></a>
The interpreter then returns control to the invoker of the method, reinstating the frame of the invoker.</blockquote><p>
<a name="return.Runtime"></a>
<p><b>Runtime Exceptions</b><br>
<blockquote><a name="250770"></a>
If the current method is a <code>synchronized</code> method and the current thread is not the owner of the monitor acquired or reentered on invocation of the method, <i>return</i> throws an <code>IllegalMonitorStateException</code>. This can happen, for example, if a <code>synchronized</code> method contains a <i>monitorexit</i> instruction, but no <i>monitorenter</i> instruction, on the object on which the method is synchronized.</blockquote><p>
<blockquote><a name="250771"></a>
Otherwise, if the virtual machine implementation enforces the rules on structured use of locks described in <a href="Threads.doc.html#22500">Section 8.13</a> and if the first of those rules is violated during invocation of the current method, then <i>return</i> throws an <code>IllegalMonitorStateException</code>.</blockquote><p>
<blockquote><a name="250650"></a>
</blockquote><p>


<hr>
<!-- This inserts footnotes--><p>
<a href="VMSpecTOC.doc.html">Contents</a> | <a href="Instructions2.doc11.html">Prev</a> | <a href="Instructions2.doc13.html">Next</a> | <a href="VMSpecIX.fm.html">Index</a>
<p>
<font size="-1"><i>The Java</i><sup><font size=-2>TM</font></sup><i> Virtual Machine Specification </i><br>
<!-- HTML generated by Suzette Pelouch on March 30, 1999 -->
<i><a href="Copyright.doc.html">Copyright &#169 1999 Sun Microsystems, Inc.</a>
All rights reserved</i>
<br>
Please send any comments or corrections to <a href="mailto:jvm@java.sun.com">jvm@java.sun.com</a>
</font>
</body></html>
